package com.ruoyi.web.controller.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.RegisterBody;
import com.ruoyi.framework.web.service.SysRegisterService;
import com.ruoyi.system.domain.OrderAo;
import com.ruoyi.system.domain.SysOrder;
import com.ruoyi.system.domain.SysOrderpro;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysOrderService;
import com.ruoyi.system.service.ISysOrderproService;
import com.ruoyi.system.service.impl.SysOrderproServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.function.Predicate;

/**
 * 注册验证
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/order")
public class SysOrderController extends BaseController {
    @Autowired
    private ISysOrderService orderService;

    @Autowired
    private ISysOrderproService orderproService;

    @GetMapping("/list")
    public AjaxResult OrderList(@RequestBody @Validated OrderAo orderAo) {
        Predicate p = (n -> n != null && !"".equals(n));
        Page<SysOrderpro> page = new Page<>(orderAo.getPage(), orderAo.getSize());
//        LambdaQueryWrapper<SysOrder> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(p.test(orderAo.getOrderName()), SysOrder::getOrderName, orderAo.getOrderName());
        IPage<SysOrderpro> page1 = orderproService.orderListPage(page,orderAo);
        return AjaxResult.success(page1);
    }

    //生成订单
    @GetMapping("/add")
    public AjaxResult OrderInfo(@RequestBody @Validated SysOrder orderAo) {
//        Predicate p = (n -> n != null && !"".equals(n));
        //可以判断订单
        boolean b = orderService.save(orderAo);
        return AjaxResult.success();
    }

}
